# Project name
PROJECT_NAME = newsletter_subs 

# Binary name
BINARY_NAME = $(PROJECT_NAME)

# Go build flags
GOBUILD_FLAGS = -v

# Go install flags
GOINSTALL_FLAGS = 

# Source files
SRC = $(shell find . -name '*.go' -type f)

# Output directory
BIN_DIR ?= ./output

# Swagger spec file
swagger:
	@echo "Generating swagger spec..."
	swag init -g ./main.go

# Build the binary
build:
	@echo "Building $(BINARY_NAME)..."
	@go build $(GOBUILD_FLAGS) -o $(BIN_DIR)/$(BINARY_NAME) main.go

# Install the binary
install:
	@echo "Installing $(BINARY_NAME)..."
	@go install $(GOINSTALL_FLAGS) ./...

# Run the binary
run:
	@echo "Running $(BINARY_NAME)..."
	@$(BIN_DIR)/$(BINARY_NAME)

# Format code
fmt:
	@echo "Formatting code..."
	@go fmt ./...

# Clean build files
clean:
	@echo "Cleaning..."
	@rm -f $(BIN_DIR)/$(BINARY_NAME)

.PHONY: build install run fmt clean
